GBML manual / Backgrounds

room_layer_visible

Shows or hides one of the room’s tile layers while the game runs: room_layer_visible(ROOM_LAYER_FRONT, false) takes the Front layer off the screen, and true puts it back.

Game Boy: not available

Game Boy Color: not available

Sega Genesis: not built yet

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

room_layer_visible(layer, on)

Arguments

NameType
layerroom_layer
onbool

Returns

Nothing.

Description

Shows or hides one of the room's tile layers while the game runs. layer is ROOM_LAYER_MAIN (the room's own tiles), ROOM_LAYER_FRONT or ROOM_LAYER_BACK; on is true to show it and false to hide it. A room that does not have that layer does nothing.

Hiding a layer changes only what is drawn. Collision belongs to the Main layer, so a hidden Main layer still blocks, and tile_index and tile_set_index still read and change the tiles of a hidden layer. The room shows every layer again the next time it loads.

Showing a layer when the console has no free background layer at that moment (other backgrounds are on the screen) does nothing, and the layer stays hidden.

A game that never calls this does not carry any of it.

Example

if (btn_pressed(BTN_A)) {
    room_layer_visible(ROOM_LAYER_FRONT, false);
}

Takes the room's Front layer off the screen when A is pressed, for example to show what is behind a roof.

On the GBA

layer is ROOM_LAYER_MAIN (the room’s own tiles), ROOM_LAYER_FRONT or ROOM_LAYER_BACK; a room with no such layer does nothing. Hiding a layer changes only what is drawn: collision belongs to the Main layer, so a hidden Main layer still blocks, and tile_index and tile_set_index still read and change a hidden layer. The room shows every layer again when it loads again. Showing a layer when the console has no free background layer right now (other backgrounds are showing) does nothing, and the layer stays hidden. A game that never calls this carries none of it.

See also: room_layer_scroll_speedtile_indextile_set_indextile_layer_set_activeBackgrounds